import { isLocal } from '@utils/auth';
import isWHITELIST from './whiteList';
import { isNullPm } from '@/utils/baseMethods';

/**
 * 有问题需修复
 * @param to
 * @returns
 */
const befroeSrart = (to: any) => {
  // console.log(to)
  // if (to.path == '/') {
  //   return { path: '/buyingRequisition' };
  // }
  // if (isNullPm(localStorage.getItem('BBSDIOS')) && to.path != '/login') {
  //   return { path: '/login' };
  // } else if (!isNullPm(localStorage.getItem('BBSDIOS')) && to.path == '/login') {
  //   return { path: '/buyingRequisition' };
  // }

  // if (isNullPm(localStorage.getItem('TOKEN')) && to.path != '/login') {
  //   return { path: '/login' };
  // } else if (!isNullPm(localStorage.getItem('TOKEN')) && to.path == '/') {
  //   return { path: '/buyingRequisition' };
  // } else if (!isNullPm(localStorage.getItem('TOKEN')) && to.path == '/login') {
  //   return { path: '/buyingRequisition' };
  // }
  // if (isNullPm(localStorage.getItem('TOKEN')) && to.path != '/login') {
  //   return { path: '/login' };
  // } else if (!isNullPm(localStorage.getItem('TOKEN')) && to.path == '/') {
  //   return { path: '/userModel' };
  // } else if (!isNullPm(localStorage.getItem('TOKEN')) && to.path == '/login') {
  //   return { path: '/userModel' };
  // }

    if(to.path == '/' || to.path == ''){
      return {path: '/queyrOddModel'}
    }


    //这里
    // if(isNullPm(localStorage.getItem('userId')) && to.path != '/login'){
    //   return {path: '/login'}
    // }else if (!isNullPm(localStorage.getItem('userId')) && to.path == '/') {
    //   return { path: '/queyrOddModel' };
    // } else if (!isNullPm(localStorage.getItem('userId')) && to.path == '/login') {
    //   return { path: '/queyrOddModel' };
    // }


  /**
   * @routerList 所有无权限路由必须在这边注册过
   */
  // if (isLocal('token')) {
  //   if (to.fullPath.indexOf('login') != -1) {
  //     return { path: '/' };
  //   }
  // } else {
  //   if (isWHITELIST(to.name) && to.fullPath.indexOf('login') == -1) {
  //     return { path: '/login' };
  //   } else {
  //     return true;
  //   }
  // }
  // return true;
};

export default befroeSrart;
